# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-motorola-peregrine
pkgdesc="Moto G 4G (2013)"
pkgver=2
pkgrel=1
url="https://postmarketos.org"
license="MIT"
arch="armv7"
options="!check !archcheck"
depends="mkbootimg postmarketos-base soc-qcom-msm8226"
makedepends="devicepkg-dev"
subpackages="
	$pkgname-kernel-downstream:kernel_downstream
	$pkgname-kernel-mainline:kernel_mainline
	$pkgname-nonfree-firmware:nonfree_firmware
	$pkgname-x11
	"
source="
	deviceinfo
	xorg.conf
	modules-initfs.mainline
	"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
}

kernel_downstream() {
	pkgdesc="Downstream kernel"
	depends="linux-motorola-peregrine msm-fb-refresher"
	devicepkg_subpackage_kernel $startdir $pkgname $subpkgname
}

kernel_mainline() {
	pkgdesc="Close to mainline kernel"
	depends="linux-postmarketos-qcom-msm8226"
	devicepkg_subpackage_kernel $startdir $pkgname $subpkgname
}

x11() {
	install_if="$pkgname-kernel-downstream=$pkgver-r$pkgrel xorg-server"
	depends="
		libinput
		xf86-input-libinput
		xf86-video-fbdev"
	install -Dm644 "$srcdir"/xorg.conf \
		"$subpkgdir"/etc/X11/xorg.conf.d/10-peregrine.conf
}

nonfree_firmware() {
	pkgdesc="Wifi firmware"
	depends="firmware-motorola-titan"
	mkdir "$subpkgdir"
}

sha512sums="
80b37878e8468fc5002364da68bc7eb18d711c710d9ee8cae0ccd838a61643f79ae49d2875a0abffda78953474a7ca8da3ed1373b09ec66bfff926e5447a160a  deviceinfo
f86ef35730b89bcc8160c08db7a7fcd0970adf60c0b77af68bac397de49c0d1783e6b8db1762380c9bf874aff2d030c6f44ecb75c803d69e79ede11376409369  xorg.conf
01b3f81f77732b7bc32e01e1c242a30f03b7c02da3aa830e3eb21b6f10458616cc8752d532405c66cd54f488c53962cf1901ebe30019ddcd572ea13445e6d28b  modules-initfs.mainline
"
